@extends('app')

@section('content')
<link rel="stylesheet" type="text/css" href="{{ asset('/jquery-date/dateRange.css') }}" />
<script src="{{ asset('/jquery-date/dateRange.js') }}" type="text/javascript"></script>

<!-- 预览icon -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="color:#2ECC71;">认证图标</h4>
      </div>
      <div class="modal-body" id="modal-body">

      </div>
    </div>
  </div>
</div>

<!-- 审核不通过的原因 -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="color:#2ECC71;">认证不通过原因</h4>
      </div>
      <div class="modal-body" id="modal-body">
        <form method="post" id="form_reson" action="/admin/enterprise/company_auth/reson">
          <div class="form-group">
            <label for="message-text" class="control-label">不通过理由:</label>
            <textarea class="form-control" name="reson" id="message-text"></textarea>
            <input type="hidden" name="company_id" id="company_id" value="0" />
            <input type="hidden" name="status" id="status" value="0" />
            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onclick="$('#form_reson').submit();">提交</button>
      </div>
    </div>
  </div>
</div>
<!-- 审核不通过的原因 结束 -->

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="tabbable" id="tabs-876069">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="{{ url('/admin/enterprise/company_auth')}}">企业认证</a>
                    </li>
                    <li>
                        <a href="#panel-952476" data-toggle="tab">搜索</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <!--列表开始-->
                    <div class="tab-pane active" id="panel-656128">
                        <h5 class="sub-header"></h5>
                        <div class="table-responsive">
                          <table class="table table-striped">
                            <thead>
                              <tr>
                                <th>编号</th>
                                <th>企业名称</th>
                                <th>法人</th>
                                <th>身份证</th>
                                <th>组织机构代码</th>
                                <th>营业执照</th>
                                <th>状态</th>
                                <th>审核</th>
                              </tr>
                            </thead>
                            <tbody>
                            @foreach($infos as $res)
                              @if (count($res->authinfo)>0)
                                <tr id="news_{{ $res->id }}">
                                  <td>{{ $res->id }}</td>
                                  <td>
                                    <span>
                                      {{ $res->name }}
                                    </span>
                                  </td>
                                  <td>
                                    <span style="">
                                      {!! $res->authinfo->corporation !!}
                                    </span>
                                  </td>
                                  <td>
                                      <span class="glyphicon glyphicon-eye-open " style="color: #2ECC71;cursor: pointer;" onclick="view('/admin/enterprise/company_auth/viewID','company_id',{{ $res->id }}, '{{ csrf_token() }}', '身份证扫描件')">
                                      </span>
                                  </td>
                                  <td>
                                      <span class=" " style="">
                                        {{ $res->authinfo->organization }}
                                      </span>
                                  </td>
                                  <td>
                                      <span class="glyphicon glyphicon-eye-open " style="color: #2ECC71;cursor: pointer;" onclick="view('/admin/enterprise/company_auth/viewPermits','company_id',{{ $res->id }}, '{{ csrf_token() }}', '营业执照')">
                                      </span>
                                  </td>
                                  <td>
                                      <span>
                                        @if ($res->authinfo->status == 0)
                                          <span style="color:#F1C40F;">
                                            未审核
                                          </span>
                                        @elseif ($res->authinfo->status == 1)
                                          <span style="color:#2ECC71;">
                                            审核通过
                                          </span>
                                        @else
                                          <span style="color:#E74C3C;cursor:pointer;" data-toggle="tooltip" data-placement="top" title="点击查看不通过理由" onclick="viewInfo('/admin/enterprise/company_auth/viewReson', 'company_id', {{ $res->id }},'{{ csrf_token() }}', '审核不通过理由')">
                                            审核不通过
                                          </span>
                                        @endif
                                      </span>
                                  </td>
                                  <td>
                                      <button type="button" class="btn btn-success btn-sm" onclick="approved('/admin/enterprise/company_auth/status', {{ $res->id }}, 1,'{{ csrf_token() }}')"
                                        @if ($res->authinfo->status == 1) disabled="disabled" @endif>通过</button>
                                      <button type="button" class="btn btn-danger btn-sm" onclick="approved('/admin/enterprise/company_auth/status', {{ $res->id }}, 2,'{{ csrf_token() }}')"
                                       @if ($res->authinfo->status == 2) disabled="disabled" @endif>不通过</button>

                                  </td>
                                </tr>
                              @endif
                            @endforeach
                            </tbody>
                          </table>
                        </div>
                        <div>{!! $infos->render() !!} </div>
                    </div>
                    <!--列表结束-->

                    <!--搜索开始-->
                    <div class="tab-pane " id="panel-952476">
                        <div style="width: 95%;margin: auto;padding-top: 40px;">
                            <div style="width: 50%;float: left;">
                              <form class="form-horizontal" action="/admin/enterprise/company_auth" method="get">
                                <div class="form-group">
                                  <label for="inputEmail3" style="padding-left:0px;" class="col-sm-2 control-label">企业名称</label>
                                  <div class="col-sm-10">
                                    <input type="text" class="form-control" id="inputEmail3" placeholder="" name="company_name">
                                  </div>
                                </div>
                                  <div class="form-group">
                                    <label for="inputPassword3" style="padding-left:0px;" class="col-sm-2 control-label">认证类别</label>
                                    <div class="col-sm-10">
                                      <select name="auth_id" id="" class="form-control">
                                        @foreach ($auths as $at)
                                          <option value="{{ $at->auth_id }}">{{ $at->name }}</option>
                                        @endforeach
                                      </select>
                                    </div>
                                  </div>

                                  <div class="form-group">
                                    <label for="inputPassword3" style="padding-left:0px;" class="col-sm-2 control-label">认证时间</label>
                                    <div class="col-sm-10 pad-t-10" >
                                      <div class="ta_date" id="div_date1">
                                          <span class="date_title" id="date1"></span>
                                          <a class="opt_sel" id="input_trigger1" href="#">
                                              <i class="i_orderd"></i>
                                          </a>
                                      </div>
                                      <div id="datePicker1"></div>
                                    </div>
                                  </div>
                                  {!! csrf_field() !!}
                                  <input type="hidden" name="auth_at_start" value="" />
                                  <input type="hidden" name="auth_at_end" value="" />
                                  <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                      <button type="submit" class="btn btn-default">搜索</button>
                                    </div>
                                  </div>
                                </form>
                            </div>

                        </div>
                    </div>
                    <!--搜索结束-->
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
  // 鼠标滑过出现提示
  $(function () {
    $('[data-toggle="tooltip"]').tooltip();

    // 初始化 隐藏域的日期参数
    $('input[name="auth_at_start"]').val(start);
    $('input[name="auth_at_end"]').val(end);
  })

  // 日期选择
  var start = showTime(-1); //当前日期前1天日期
  var end = showTime(1); //当前日期
  var dateRange1 = new pickerDateRange('date1', {
                isTodayValid: false,
                startDate: start,
                endDate: end,
                needCompare: false,
                defaultText: ' 至 ',
                autoSubmit: true,
                inputTrigger: 'input_trigger1',
                theme: 'ta',
                success: function (obj) {
                    $("#dCon2").html('开始时间 : ' + obj.startDate + '<br/>结束时间 : ' + obj.endDate);
                    $('input[name="auth_at_start"]').val(obj.startDate);
                    $('input[name="auth_at_end"]').val(obj.endDate);
                }
            });

</script>
@endsection
